function loadImg(src) {
  const p = new Promise(
    (resolve,reject) => {
      const img = document.createElement('img')
      img.onload = () => {
        resolve(img)
      }
      img.onerror = () => {
        reject( new Error('加载失败'))
      }
      img.src = src
    }
   
  )
  return p
}


const url1 = 'https://i0.hdslb.com/bfs/sycp/creative_img/202107/14b485d967a5564a6b48188514230f78.jpg'
loadImg(url1).then(img1 => {
  console.log(img1.width);
  return img1
}).then(img1 => {
  console.log(img1.height);
}).catch(err => {
  console.log(err);
})